package com.itany.mapping;

import com.itany.entity.User;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@RestController
public class UserMapping {
    List<User> list = new ArrayList<>(Arrays.asList(
            new User("zhangsan", "6666"),
            new User("lisi", "8888"),
            new User("wangwu", "9999")
    ));
//    注册-->添加
    public boolean addUser(User user){
        list.add(user);
        return true;
    }
//    登录-->查询
    public User selectUser(User user){
        boolean flag=list.contains(user);
        return flag?user:null;
    }

    public List<User> selectAllUser() {
        return list;
    }

    //更新用户 修改用户密码
    public User updatePwd(User user,String pwd){
        user.setPwd(pwd);
        return user;
    }
    //删除用户
    public boolean deleteUser(User user){
        return list.remove(user);
    }

}
